package cn.sixmillions.yuqueblog.controller;

import cn.sixmillions.yuqueblog.entity.Repo;
import cn.sixmillions.yuqueblog.entity.Toc;
import cn.sixmillions.yuqueblog.service.IRepoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 语雀仓库API
 * @author: sixmillions
 * @since: 2021/12/10
 **/
@RestController
@RequestMapping("/api/repo")
@Api(value = "Repo Controller", tags = "Repo")
public class RepoController {

    @Autowired
    private IRepoService repoService;

    /**
     * 获取知识库列表
     */
    @GetMapping("/list/{login}")
    @ApiOperation(value = "Repo List", notes = "知识库列表")
    public List<Repo> getRepoList(@PathVariable String login) {
        return repoService.getRepoList(login);
    }

    @GetMapping("/toc")
    @ApiOperation(value = "Toc", notes = "知识库目录")
    public List<Toc> getToc(String namespace) {
        return repoService.getToc(namespace);
    }

}
